parity: add LCOW HCS document parity tests between legacy and v2 builders#2629
Open
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Open
parity: add LCOW HCS document parity tests between legacy and v2 builders#2629shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
shreyanshjain7174 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
rawahars
requested changes
Mar 14, 2026
Contributor
rawahars
left a comment
There was a problem hiding this comment.
Left comments.
Also, please ensure that the comments are verbose and easy to understand.
shreyanshjain7174
pushed a commit
to shreyanshjain7174/hcsshim
that referenced
this pull request
Mar 16, 2026
Address review feedback from PR microsoft#2629. Major changes: Source changes (internal/uvm/): - Export VerifyOptions, MakeLCOWDoc, MakeLCOWSecurityDoc as public functions so they can be called directly from the test package. - Remove MakeLCOWDocument composite wrapper — test assembles the pipeline itself using the exported primitives. - Add NewUtilityVMForDoc constructor in types.go. This is needed because MakeLCOWDoc takes a *UtilityVM parameter and reads its unexported fields (scsiControllerCount, vpmemMaxCount, etc). The test cannot set these fields directly from outside the package, so NewUtilityVMForDoc creates a minimal UtilityVM with only the fields needed for document generation. - Original source code comments preserved — only function names changed from lowercase to uppercase. Test changes (test/parity/vm/): - Moved from test/parity/ to test/parity/vm/ for future WCOW support. - Removed functional build tag — these are not functional tests. - Removed all normalization (nil-vs-empty, map sorting, owner zeroing). cmp.Diff handles maps natively. Real differences are not masked. - Merged pipeline helpers into hcs_document_creator_test.go. - Removed helpers_test.go — setupBootFiles and jsonToString moved inline. - Generic doc.go that covers both LCOW and future WCOW. - All test cases explicitly populate every field (CPU, memory, MMIO, QoS, CPUGroupID) so comparison always checks populated values, not defaults. - Use maps.Clone for annotation copying. - Use testing.Verbose() to gate debug logging. - Descriptive error messages throughout. All 8 tests pass (3 document parity + 5 field parity). Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
44a4cea to
b6a131c
Compare
Contributor
Author
|
Thanks for the thorough review @rawahars — really appreciate the detailed feedback. Pushed a full restructure addressing all 26 comments: Source changes:
Test restructure:
Key finding during testing: The v2 builder unconditionally initializes |
This was referenced Mar 16, 2026
rawahars
requested changes
Mar 16, 2026
shreyanshjain7174
pushed a commit
to shreyanshjain7174/hcsshim
that referenced
this pull request
Mar 16, 2026
- Rename package from 'vm' to 'vmparity' for clarity - Rename hcs_document_creator_test.go to hcs_lcow_document_creator_test.go to distinguish LCOW-specific helpers from future WCOW - Revert MakeLCOWSecurityDoc back to unexported (not used in tests) - Simplify doc.go to match codebase convention (minimal, no file layout) - Update NewUtilityVMForDoc comment explaining why it must stay in uvm package (UtilityVM fields are unexported) Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
3f1b638 to
72d9362
Compare
Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
72d9362 to
d255057
Compare
shreyanshjain7174
pushed a commit
to shreyanshjain7174/hcsshim
that referenced
this pull request
Mar 20, 2026
Address review feedback from PR microsoft#2629. Major changes: Source changes (internal/uvm/): - Export VerifyOptions, MakeLCOWDoc, MakeLCOWSecurityDoc as public functions so they can be called directly from the test package. - Remove MakeLCOWDocument composite wrapper — test assembles the pipeline itself using the exported primitives. - Add NewUtilityVMForDoc constructor in types.go. This is needed because MakeLCOWDoc takes a *UtilityVM parameter and reads its unexported fields (scsiControllerCount, vpmemMaxCount, etc). The test cannot set these fields directly from outside the package, so NewUtilityVMForDoc creates a minimal UtilityVM with only the fields needed for document generation. - Original source code comments preserved — only function names changed from lowercase to uppercase. Test changes (test/parity/vm/): - Moved from test/parity/ to test/parity/vm/ for future WCOW support. - Removed functional build tag — these are not functional tests. - Removed all normalization (nil-vs-empty, map sorting, owner zeroing). cmp.Diff handles maps natively. Real differences are not masked. - Merged pipeline helpers into hcs_document_creator_test.go. - Removed helpers_test.go — setupBootFiles and jsonToString moved inline. - Generic doc.go that covers both LCOW and future WCOW. - All test cases explicitly populate every field (CPU, memory, MMIO, QoS, CPUGroupID) so comparison always checks populated values, not defaults. - Use maps.Clone for annotation copying. - Use testing.Verbose() to gate debug logging. - Descriptive error messages throughout. All 8 tests pass (3 document parity + 5 field parity). Signed-off-by: Shreyansh Sancheti <shsancheti@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds parity tests that compare the HCS ComputeSystem documents produced by the
legacy shim pipeline and the new v2 LCOW builder (
lcow.BuildSandboxConfig).Both paths receive the same inputs — annotations, shim options, and devices —
so the resulting documents should be structurally identical.
How it works
Each test case feeds identical inputs to both pipelines:
Changes
internal/uvm/create_lcow.go: Export
MakeLCOWDocandVerifyOptionsforuse in parity tests. These generate the HCS document and validate options
without creating a VM or calling HCS.
internal/uvm/types.go: Add
NewUtilityVMForDocconstructor — creates aminimal
UtilityVMwith the fields needed byMakeLCOWDoc. Must live in theuvmpackage because allUtilityVMfields are unexported.internal/uvm/create.go, internal/uvm/create_wcow.go: Rename
verifyOptions→VerifyOptions(exported)..github/workflows/ci.yml: Include
test/parity/vm/in the non-functionaltest step.
test/parity/vm/ (new
vmparitypackage):doc.go— package documentationhcs_lcow_document_creator_test.go— helper functions that wire the legacyand v2 pipelines:
buildLegacyLCOWDocument,buildV2LCOWDocument,setupBootFiles,jsonToStringlcow_doc_test.go— 3 document parity tests, 5 sandbox option field checks,and a
checkSandboxOptionsParityhelper for extensibilityTest cases
Results
All 8 tests pass (3 document + 5 field).
More permutations (boot modes, VPCI devices, VPMem sizes, NUMA topology) will
be added in follow-up PRs once this foundation is reviewed and merged.